/*
 * Block comments with details of changes
 */
public without sharing class NoContractApplicationDetailController
{
    public String msg {get;private set;}
    public Boolean isErr {get; private set;}//错误
    public Boolean isSuccess {get; private set;}//是否保存成功
    public String backId {get; private set;}
    public class ControllerException extends Exception {}
    private Boolean isNew ; 
    private NoContractInstrumentApplication__c noc ;
    private  Map<String,DataUtil.SObjectBean> stageObjectMap;
    public String dataJson {get; private set;} 
    public String saveJson {get; set;}


    public NoContractApplicationDetailController(){
        backId = System.currentPageReference().getParameters().get('id');
        isNew = false;
        noc =  new NoContractInstrumentApplication__c();
        stageObjectMap = new  Map<String,DataUtil.SObjectBean>();

    }

    private List<Object> getCombobox(){
        Map<String,String> comboxs = ImportObject.getPicklistValues('NoContractInstrumentApplicationDetail__c', 'ExpectedProcessingWay__c', true);
        List<Object> combos = new List<Object>();
        for(String key : comboxs.keySet()){
            Map<String,String> opt = new Map<String,String>();
            opt.put('id', key);
            opt.put('text',comboxs.get(key));
            combos.add(opt);
        }
        return combos ;
    }

    public void init(){

        try {
            
            if(backId == null ) setErr('页面打开错误!');
            if(Id.valueOf(backId).getSobjectType() == NoContractInstrumentApplication__c.SObjecttype){
                //编辑
                User u =[select Id ,Profile.Name  from User where Id =:UserInfo.getUserId()];
                noc = [select Id , stage__c , Customer__c , Opportunity__c , Contancts__c from  NoContractInstrumentApplication__c where Id =: backId];

                if( !u.Profile.Name.contains('财务') && ( noc.stage__c == '已批准' || noc.stage__c == '审批中') )setErr(noc.stage__c +' 不能修改!');
                //if( noc.Opportunity__c == null ) setErr( '关联合同 不能空!');
            }else if(Id.valueOf(backId).getSobjectType() == Opportunity.SObjecttype){
                isNew = true;
                noc.stage__c = '草案中';
               // noc.Contract__c = backId;
                noc.Opportunity__c = backId;
                //判断合同的状态
               //Contract__c con = [select Id , Status__c,RecordType.DeveloperName  from Contract__c where Id=: backId ];
                //if(con.Status__c != 'OA审批中' &&  con.Status__c != '已推送OA' &&  con.Status__c != '已生效' )setErr('合同'+con.Status__c+'状态不能申请!');

                //if(con.RecordType.DeveloperName != 'TerminalContract') setErr('只有签约/续签的相关合同才能发起申请!');



            }else{
                setErr('页面打开错误!');
            }

            Map<String,Object> dataMap = new Map<String,Object>();

            dataMap.put('detail', getDetails());
            List<Object> tmp = getProductFromContract();
            if(tmp.isEmpty() )throw new DmlException('请先添加合作产品明细!');
            dataMap.put('search',tmp );

            //字段
             Map<String,Set<String>> fieldsmap = getFields();
             //字段详情
             Map<String, List<DataUtil.FieldBean>> fbMap = DataUtil.getFieldsBean(fieldsmap,stageObjectMap);
            
            //字段赋值
             Map<String,List<DataUtil.FieldBean>> fields = DataUtil.setFieldsValue(fbMap,DataUtil.getBaseInfo(fbMap,stageObjectMap) );
                         

            dataMap.put('base',fields);
            dataMap.put('combox',getCombobox());
            dataMap.put('baseObject',DataUtil.getBaseObjectMap(stageObjectMap)); 

            dataJson = EncodingUtil.urlEncode(JSON.serialize(dataMap),'UTF-8') ;

        }catch (Exception e) {
             ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.ERROR ,e.getMessage()+e.getStackTraceString()));

        }
        
    }

     public Map<String,Set<String>>  getFields(){
        Map<String,Set<String>> fieldsMap  = new  Map<String,Set<String>>();
        
            DataUtil.SObjectBean sb = new DataUtil.SObjectBean();

            sb.title =''; 
            sb.objname = 'NoContractInstrumentApplication__c';
            sb.stype = DataUtil.getSObjectType('NoContractInstrumentApplication__c');
            if(!isNew)sb.idvalue = noc.Id;
            sb.type = 'base';
            if(!isNew)sb.condition = ' where Id =\''+noc.Id+'\'';
            stageObjectMap.put('NoContractInstrumentApplication__c',sb );
            Set<String>  fields = new Set<String>{'AdvanceCharge__c','ScannedContract__c','PaymentAmount__c','Customer__c','Reason__c','Contancts__c'};
         
            fieldsMap.put('NoContractInstrumentApplication__c', fields);
        
        return fieldsMap;
    }


    private void setErr(String message){
        isErr  =true;
        throw new ControllerException(message);
    }
    public void setNil(){
        dataJson = '[]';
        saveJson = '{}';
    } 

    private List<ProductBean> getDetails(){

        List<ProductBean> tmp = new List<ProductBean>();
        if(!isNew){

            for(NoContractInstrumentApplicationDetail__c non :
             [select Id ,ApplicationInstrument__r.Product__r.ProductName__c,ApplicationInstrument__r.Product__r.Model__c, ApplicationInstrument__r.QuoteProduct__r.Quote__r.Name,
             ApplicationInstrument__r.InstrumentPolicy__r.InstrumentPolicy__r.Name,ApplicationInstrument__r.Measure_Calculate_Product__r.Measure_Calculate__r.Name,
             ApplicationInstrument__c,ApplicationInstrument__r.Product__r.Spec__c,ApplicationInstrument__r.Quantity__c,ApplicationInstrument__r.ApplicationQuantity__c,
             ApplicationInstrument__r.DeliveryQuantity__c, ExpectedProcessingTime__c,Time__c,ApplicationInstrument__r.InstrumentPolicy__c, ApplicationInstrument__r.EndCustomer__r.Name,
              ApplicationInstrument__r.QuoteProduct__c,ApplicationInstrument__r.Measure_Calculate_Product__c ,Number__c ,ExpectedProcessingWay__c 
             from NoContractInstrumentApplicationDetail__c where NoContractInstrumentApplication__c =: noc.Id   ]){

                tmp.add(new ProductBean(non));

            }
        }
        return tmp;
    }

    private List<ProductBean> getProductFromContract(){

        List<ProductBean> tmp = new List<ProductBean>();
        System.debug('NoContractApplicationDetailController==>' + noc.Opportunity__c);


        for(ContractProduct__c cp :
             [select Id ,Product__r.ProductName__c,Product__r.Model__c, QuoteProduct__r.Quote__r.Name,ApplicationQuantity__c,
             InstrumentPolicy__r.InstrumentPolicy__r.Name,Measure_Calculate_Product__r.Measure_Calculate__r.Name,
             Product__r.Spec__c,Quantity__c,Measure_Calculate_Product__c,InstrumentPolicy__c, EndCustomer__r.Name,
             DeliveryQuantity__c,QuoteProduct__c ,BloodSugarOrderDetail1__r.BloodSugarProduct__r.Name
             from ContractProduct__c where Opportunity__c =: noc.Opportunity__c and Opportunity__c != null   ]){

               if(cp.ApplicationQuantity__c == null || cp.ApplicationQuantity__c < cp.Quantity__c ) tmp.add(new ProductBean(cp));

            }

            return tmp;


    } 

    public void upload(){
        msg = '';
        SavePoint sp = Database.setSavePoint();
        try{

            Map<String,Object> dataObject = (Map<String,Object> )JSON.deserializeUntyped(saveJson);

            System.debug(dataObject);
           String s = (String)dataObject.get('file');

           String format = (String)dataObject.get('format');
           String rename = EncodingUtil.urlDecode((String)dataObject.get('rename'), 'UTF-8') ;

           String  fileName = EncodingUtil.urlDecode((String)dataObject.get('filename'), 'UTF-8') ;

           Blob body = s != null ?EncodingUtil.base64Decode(s.substring(s.indexOf(',')+1) ) : null;
           
           String attName = null;
            if(String.isBlank(rename) == false){
                attName = rename +'.'+ format;
            }else{
                attName = filename;
            }
            if(!attName.contains('合同'))throw new DmlException('请命名为**合同扫描件');

             upsert noc ;
            if(body != null && s.length() > 0 ){
              Attachment att = new Attachment();
              att.Name = attName;
              att.Body = body;
              att.ParentId = noc.Id ;
              insert att;
            }
            
        
           msg = '上传成功!';
           isSuccess = true;/**/
        }catch(Exception e){
            Database.rollback(sp);
            msg = '上传失败'+e.getMessage();

        }
         saveJson = '';
        
    }


    public void save(){
        msg = '';
        try {
            isSuccess = false;
            Map<String , Object> saveMap = (Map<String ,Object>)JSON.deserializeUntyped(EncodingUtil.urlDecode(saveJson,'UTF-8'));

            Map<String,Object> baseMap = (  Map<String,Object>)saveMap.get('base');

            Map<String,Set<String>> fieldsMap = getFields();
            Map<String,DataUtil.FieldBean> fbeanMap = DataUtil.getFieldsInfo(NoContractInstrumentApplication__c.SObjecttype,fieldsMap.get('NoContractInstrumentApplication__c'));
            for(String field : baseMap.keySet()){
                noc.put(field, DataUtil.dataHandler(baseMap.get(field),fbeanMap.get(field).type.toUpperCase() ));
            }


            if(noc.ScannedContract__c =='是'  ){

                if(noc.Id == null) throw new DmlException('请先上传附件!');
                System.debug(noc.Id );

                NoContractInstrumentApplication__c noc1 = [select Count__c from NoContractInstrumentApplication__c where Id=:noc.Id];
                if(noc1.Count__c == null || noc1.Count__c == 0) throw new DmlException('请先上传附件!');


            }
            List<Object> saveList = (List<Object>)saveMap.get('datas');

            List<NoContractInstrumentApplicationDetail__c> nodList =new List<NoContractInstrumentApplicationDetail__c>();
            Set<Id> exsets = new Set<Id>();
            for (Object o   : saveList ) {
                 Map<String,Object> mo = ( Map<String,Object>)o;

                NoContractInstrumentApplicationDetail__c nod = new NoContractInstrumentApplicationDetail__c();
                nod.Id = mo.get('Id') == null ? null : DataUtil.getStringValue(mo.get('Id'));
                if(nod.Id != null ) exsets.add(nod.Id);
                nod.Number__c = DataUtil.getDecimalValue(mo.get('num'));
                nod.ApplicationInstrument__c = DataUtil.getStringValue(mo.get('cpId'));
                nod.Time__c = mo.get('apptime') == null ? null : Date.valueOf(DataUtil.getStringValue(mo.get('apptime')));
                System.debug('NoContractApplicationDetailController==>'+ mo);
                nod.ExpectedProcessingTime__c = mo.get('expecttime') == null ? null : Date.valueOf(DataUtil.getStringValue(mo.get('expecttime')));
                nod.ExpectedProcessingWay__c = DataUtil.getStringValue(mo.get('expectway'));
                nod.RelevantQuotations__c = DataUtil.getStringValue(mo.get('qId'));
                nod.RelevantPolicies__c = DataUtil.getStringValue(mo.get('pId'));
                nod.RelevantMeasurements__c = DataUtil.getStringValue(mo.get('mId'));

                
                nodList.add(nod);

            }
            Savepoint sp = Database.setSavepoint();
            try {

                upsert noc;
                if(exsets.size() > 0 ) delete [select Id from NoContractInstrumentApplicationDetail__c  where NoContractInstrumentApplication__c =:noc.Id and Id not in: exsets];

                for (NoContractInstrumentApplicationDetail__c nod :nodList ) {
                    if(nod.Id == null ) nod.NoContractInstrumentApplication__c = noc.Id;
                }
                if(nodList.size() > 0 ) upsert nodList;

                isSuccess = true;
                msg = '保存成功!';
                backId = noc.Id;
            }catch (Exception e) {
                Database.rollback(sp);
                if(isNew) noc.Id = null;

                msg = '保存失败:'+e.getMessage();
            }
        
            
        }catch (Exception e) {
            
            msg = '保存失败:'+e.getMessage();   
        }
        

    }




    public class ProductBean{

        public String productName;//产品名
        public String relatedName;//来源
        public String cpId;//合同仪器Id ;
        public String spec ; //规格/型号
        public String model;//
        public Decimal num; //数量
        public String apptime ; //申请发货时间
        public String expecttime;//预计处理时间
        public Decimal total ;//签约数量
        public Decimal cannum ; //可申请数量
        public String Id;
        public String qId;//报价明细
        public String mId;//测算明细
        public String pId;//政策明细
        public String expectway;//
        public String terminal;



        public ProductBean(ContractProduct__c cp ){

            productName = cp.Product__r.ProductName__c;

            if(cp.QuoteProduct__r.Quote__r.Name != null )relatedName = cp.QuoteProduct__r.Quote__r.Name;

            if(cp.InstrumentPolicy__r.InstrumentPolicy__r.Name != null ) relatedName = cp.InstrumentPolicy__r.InstrumentPolicy__r.Name;

            if(cp.Measure_Calculate_Product__r.Measure_Calculate__r.Name != null ) relatedName = cp.Measure_Calculate_Product__r.Measure_Calculate__r.Name;
            if(cp.BloodSugarOrderDetail1__r.BloodSugarProduct__r.Name != null ) relatedName = cp.BloodSugarOrderDetail1__r.BloodSugarProduct__r.Name;

            cpId = cp.Id;

            spec = cp.Product__r.Spec__c;
            model = cp.Product__r.Model__c;
            total = cp.Quantity__c;

            cannum = (cp.Quantity__c == null ? 0 : cp.Quantity__c )- (cp.ApplicationQuantity__c == null ? 0 : cp.ApplicationQuantity__c) ;

            qId = cp.QuoteProduct__c;
            mId = cp.Measure_Calculate_Product__c;
            pId = cp.InstrumentPolicy__c;

            terminal = cp.EndCustomer__r.Name ;




        }

        public ProductBean(NoContractInstrumentApplicationDetail__c non){
            Id = non.Id;
            expectway = non.ExpectedProcessingWay__c;
            productName = non.ApplicationInstrument__r.Product__r.ProductName__c;
            if(non.ApplicationInstrument__r.QuoteProduct__r.Quote__r.Name != null )relatedName = non.ApplicationInstrument__r.QuoteProduct__r.Quote__r.Name;

            if(non.ApplicationInstrument__r.InstrumentPolicy__r.InstrumentPolicy__r.Name != null ) relatedName = non.ApplicationInstrument__r.InstrumentPolicy__r.InstrumentPolicy__r.Name;

            if(non.ApplicationInstrument__r.Measure_Calculate_Product__r.Measure_Calculate__r.Name != null ) relatedName = non.ApplicationInstrument__r.Measure_Calculate_Product__r.Measure_Calculate__r.Name;

            cpId = non.ApplicationInstrument__c;

            spec = non.ApplicationInstrument__r.Product__r.Spec__c;
            model = non.ApplicationInstrument__r.Product__r.Model__c;

            total = non.ApplicationInstrument__r.Quantity__c;

            num = non.Number__c;

            cannum = (non.ApplicationInstrument__r.Quantity__c != null ? non.ApplicationInstrument__r.Quantity__c :  0 )  - (non.ApplicationInstrument__r.ApplicationQuantity__c != null ? non.ApplicationInstrument__r.ApplicationQuantity__c :  0 )   ;

            apptime =  non.Time__c == null ? '': Utils.date2string(non.Time__c, 'yyyy-MM-dd');
            expecttime = non.ExpectedProcessingTime__c == null  ? '' : Utils.date2string(non.ExpectedProcessingTime__c, 'yyyy-MM-dd');

            qId = non.ApplicationInstrument__r.QuoteProduct__c;
            mId = non.ApplicationInstrument__r.Measure_Calculate_Product__c;
            pId = non.ApplicationInstrument__r.InstrumentPolicy__c;

            terminal = non.ApplicationInstrument__r.EndCustomer__r.Name;

        }
    }   
    
}




/*
public String ncadId {get;private set;}//申请id
    public List<NoContractApplicationDetailBean> nList {get;set;}//已经存在的明细
    public List<ProductBean> pList {get;set;}//筛出的产品
    public Boolean successCallBack {get;private set;}//是否保存成功
    public NoContractInstrumentApplicationDetail__c n {get;set;}//批量修改用的明细
  //筛选条件
    public String name { get; set; }//名称
    public String brand { get; set; }//品牌
    public String serial { get; set; }//货号
    public String nccode { get; set; } //产品编码
    public String category1 { get; set; } //一级分类
    public String category2 { get; set; }//二级分类
    public String category3 { get; set; }//三级分类
    
    public List<SelectOption> cate1Opts { get; private set; }//一级分类选项
    public List<SelectOption> cate2Opts { get; private set; }//二级分类选项
    public List<SelectOption> cate3Opts { get; private set; }//三级分类选项
    public List<SelectOption> link1Opts { get;set; }
    public List<SelectOption> link2Opts { get;set; }
    
    public NoContractApplicationDetailController(ApexPages.StandardController con)
    {
        ncadId = System.currentPageReference().getParameters().get('id');
        nList = new List<NoContractApplicationDetailBean>();
        n = new NoContractInstrumentApplicationDetail__c();
        pList = new List<ProductBean>();
        category3= '仪器';
          //一级分类
        cate1Opts = new List<SelectOption>();
        cate1Opts.add(new SelectOption('', System.Label.Option_None));
        for (String str : System.Label.Product_Category1.split(',', -1)) {
            cate1Opts.add(new SelectOption(str, str));
        }
        
          // 二级分类
        cate2Opts = new List<SelectOption>();
        cate2Opts.add(new SelectOption('', System.Label.Option_None));
        for (String str : System.Label.Product_Category2.split(',', -1)) {
            cate2Opts.add(new SelectOption(str, str));
        }
            // 三级分类
        cate3Opts = new List<SelectOption>();
        cate3Opts.add(new SelectOption('', System.Label.Option_None));
        for (String str : System.Label.Product_Category3.split(',', -1)) {
            cate3Opts.add(new SelectOption(str, str));
        }
    }
    public void init(){
        
        for(NoContractInstrumentApplicationDetail__c n: [select Size__c,Time__c,Brand__c,Number__c,Instrument__c,
                Instrument__r.Name, ExpectedProcessingTime__c,SalesModel__c,Instrument__r.Spec__c,Instrument__r.Brand__c
                from NoContractInstrumentApplicationDetail__c 
                 where NoContractInstrumentApplication__c =:ncadId]){
            NoContractApplicationDetailBean nb = new NoContractApplicationDetailBean();
            nb.nad = n;
            nb.chk = false;
            nb.productName = n.Instrument__r.Name;
            nb.brand = n.Instrument__r.Brand__c;
            nb.size = n.Instrument__r.Spec__c;
            nList.add(nb);
        }
        
    }
    public void exchange(){
        List<NoContractApplicationDetailBean> stayList = new List<NoContractApplicationDetailBean>();
        for (NoContractApplicationDetailBean ipb : nList) {
            if (ipb.chk == false) {
                stayList.add(ipb);
            }
        }
        
        nList.clear();
        nList.addAll(stayList);

        Set<Id> existPid = new Set<Id>();
        for (NoContractApplicationDetailBean ipb : nList) {
            existPid.add(ipb.nad.Instrument__c);
        }
      
        // 加入已勾选的产品
        for (ProductBean p : pList) {
            if (p.chk == true && existPid.contains(p.p.Id) == false) {
                NoContractApplicationDetailBean ia = new NoContractApplicationDetailBean();
                ia.chk = false ;
                
                NoContractInstrumentApplicationDetail__c n = new NoContractInstrumentApplicationDetail__c();
                n.Instrument__c = p.p.Id;
                n.NoContractInstrumentApplication__c = ncadId;
                ia.productName = p.p.Name;
                ia.brand = p.p.Brand__c;
                ia.size = p.p.Spec__c;
                ia.nad = n;
               
                
                nList.add(ia);
            }
        } 
    
    }
    public void save(){
         Savepoint sp = Database.setSavepoint();
        try{
            List<NoContractInstrumentApplicationDetail__c> nLists = new List<NoContractInstrumentApplicationDetail__c>();
            for(NoContractApplicationDetailBean b : nList){
                nLists.add(b.nad);
            }
            System.debug(nLists);
           if(nLists.size()>0) upsert nLists;
                successCallBack = true;
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '保存成功!'));
        }catch(Exception e){
            Database.rollback(sp);
             successCallBack = false;
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));        }

    }
    ///检索
    public void search(){
        
       // Id rid=Utils.getRecordTypeIdByDevNameAndObjName('仪器型号(含竞争对手)','Product__c');

        Schema.DescribeSobjectResult m = Product__c.sObjectType.getDescribe();
        Map<String, Schema.SObjectField> fieldMap = m.fields.getMap();
        
        String sql = 'select ';
        String fields = '';
        for (String field : fieldMap.keySet()) {
            if (fields.length() > 0) {
                fields += ', '; 
            }
            fields += field;
        }
        sql += fields;
        sql += ' from Product__c where Name != null ';
        String whereStr = '';
        if (String.isBlank(name) == false) {
            whereStr += ' and Name like \'%' + name + '%\'';
        }
        if (String.isBlank(brand) == false) {
            whereStr += ' and  Brand__c like \'%' + brand + '%\'';
        }
        if (String.isBlank(serial) == false) {
            whereStr += ' and  SerialNo__c like \'%' + serial + '%\'';
        }
         if (String.isBlank(nccode) == false) {
            whereStr += ' and  NCCode__c like \'%' + nccode + '%\'';
        }
        if (String.isBlank(category1) == false) {
            whereStr += ' and  Category1__c like \'%' + category1 + '\'';
        }
        if (String.isBlank(category2) == false) {
            whereStr += ' and  Category2__c = \'' + category2 + '\'';
        }
     
     pList.clear();
    String cat2 = '';
        String cat3 = '';
        Set<String> cat2s = new Set<String>();
        Set<String> cat3s = new Set<String>(); 
        System.debug(sql + whereStr + ' limit 500');
    List<Product__c> pLists = Database.query(sql + whereStr + ' limit 500');
     for(Product__c p: pLists){
     ProductBean pb = new ProductBean();
        pb.chk = false;
        pb.p = p;
        pList.add(pb);

    if(p.Category2__c != null && p.Category2__c.length()>0)cat2s.add(p.Category2__c);
         if(p.Category3__c != null && p.Category3__c.length()>0)cat3s.add(p.Category3__c);
     }
       
        
            ///设置二级分类下拉列表
            for (String s : cat2s) {
                   cat2 = cat2 + s+ ',';
               
            }
            
            if(cat2.length()>1)cat2 = cat2.substring(0,cat2.length()-1);
            
               setLink1Opts(cat2);
         
            //设置三级级分类下拉列表
            for (String s : cat3s) {
                   cat3 = cat3 + s + ',';
               
            }
            if(cat3.length()>1)cat3 = cat3.substring(0,cat3.length()-1);
               
            setLink2Opts(cat3);
        
    }
    //获取选项列表
    private List<SelectOption> stringToSelectOption(String optStr){
    
       List<SelectOption> cateOpts = new List<SelectOption>();
      
       cateOpts.add(new SelectOption('', System.Label.Option_None));
       for (String str : optStr.split(',', -1)) {
            cateOpts.add(new SelectOption(str, str));
        }  
        return cateOpts; 
    }
    public void setLink2Opts(String  opt){
       link2Opts = stringToSelectOption(opt);
       if(pList.size()>0){
       cate3Opts = link2Opts ;
       }else{
       cate3Opts = getCate(3);
       }
    }
    public void setLink1Opts(String opt){
        link1Opts = stringToSelectOption(opt);
        if(pList.size()>0){
           cate2Opts = link1Opts;
        }else{
            cate2Opts = getCate(2);
        }
    }   
     private List<SelectOption> getCate(Integer i){
       String optStr = '';
       if(i == 0 ){
             optStr =  System.Label.Product_Category0;

       }else if(i == 1){
             optStr =  System.Label.Product_Category1;

       }else if(i == 2){
             optStr =  System.Label.Product_Category2;
       }else if(i == 3){
             optStr =  System.Label.Product_Category3;
       }         
             return stringToSelectOption(optStr);     
    }
    public class ProductBean{
        public Boolean chk {get;set;}//选中
        public Product__c p {get;set;}//产品
    
    }
    public class NoContractApplicationDetailBean{
        public Boolean chk {get;set;}//选中
        public NoContractInstrumentApplicationDetail__c nad {get;set;}//明细
        public String productName {get;set;}//产品名称
        public String size {get;set;}//规格 
        public String brand {get;set;}//品牌
    } 

*/